#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by PyCharm.
# @Project: Code_Clone_Detection_Educoder
# @File: code_format.py
# @Description: 
# @Time: 2018/12/12 15:46
# @Author: ljz

import re


def handle_java_annotation(code_information):
    i = 0
    while i < len(code_information):
        if '//' in code_information[i][0] and re.search('".*//.*"', code_information[i][0]) is None:
            code_information[i][0] = code_information[i][0].split('//')[0]
        if code_information[i][0] == '':
            del code_information[i]
            i -= 1
        elif '/*' in code_information[i][0]:
            while '*/' not in code_information[i][0]:
                del code_information[i]
            del code_information[i]
            i -= 1
        i += 1

    return code_information


def handle_python_annotation(code_information):
    i = 0
    while i < len(code_information):
        if '#' in code_information[i][0] and re.search('".*#.*"', code_information[i][0]) is None:
            code_information[i][0] = code_information[i][0].split('#')[0]
        if code_information[i][0] == '':
            del code_information[i]
            i -= 1
        elif '"""' in code_information[i][0]:
            while '"""' not in code_information[i][0]:
                del code_information[i]
            del code_information[i]
            i -= 1
        i += 1

    return code_information
